<?php
/**
 * Created by PhpStorm OF Administrator.
 * User: YUYI
 * Date: 2018/7/11 0011
 * Time: 下午 5:22
 * Administrator
 */

namespace app\common\service;


class DateService
{
    const DATE_FORMART_STRING = 'Y-m-d H:i:s';

    /**
     * 获取现在的日期
     * @return false|string
     */
    public static function now()
    {
        return date(self::DATE_FORMART_STRING);
    }

    /**
     * 获取昨天的日期
     * @return false|string
     */
    public static function lastDay()
    {
        return date('Y-m- 00:00:00',strtotime("-1 day"));
    }

    /**
     * 获取上月$day天的日期
     * @param $day
     * @return false|string
     */
    public static function lastMonth($day)
    {
        return date('Y-m-'.$day.' 00:00:00',strtotime('-1 month'));
    }

    /**
     * 获取上上月日期
     * @param $day
     * @return false|string
     */
    public static function lastLastMonth($day)
    {
        return date('Y-m-'.$day.' 00:00:00',strtotime('-2 month'));
    }
}